$(function () {
    $("#topHtml").load("/html/top.html");
    $("#footHtml").load("/html/foot.html");

    let data = myAjax("/home", "", "get");
    getHomeData(data[0].object);
    commonData = data[0].object.commonModelDto;
});
let commonData;//得到公共的公司信息和导航信息

function getHomeData(data) {

    setNewsData(data.newsList);//设置较新动态
    setProductData(data.productList);//产品展示
}


function setNewsData(data) {
    let html = '';
    for (let i = 0; i < data.length; i++) {
        html += '<div>\n' +
            '                    <h5>' + data[i].title + '</h5>\n' +
            '                    <p>' + data[i].content + '</p>\n' +
            '                </div>';

    }
    $("#homeNews").html(html);
}

function setProductData(data) {

    let html = '';
    for (let i = 0; i < data.length; i++) {
        html += i == 0 ? '<div class="float-left">' : '<div class="float-right">';
        html += '<div><img src="' + data[i].imgHref + '" height="300" width="300"/></div>\n' +
            '                <div>\n' +
            '                    <div>' + data[i].name + '</div>\n' +
            '                    <div>' + data[i].content + '</div>\n' +
            '                </div>\n' +
            '            </div>';
    }
    $("#homeProduct").html(html);
}